home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 1 / QRZ Ham Radio Callsign Database - December 1993.iso / ucsd / packet / tcpip / amiga / asrc29k.lha / udpcmd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-08  |  1.2 KB  |  69 lines

  1. /* UDP-related user commands */
  2. #include <stdio.h>
  3. #include "global.h"
  4. #include "mbuf.h"
  5. #include "netuser.h"
  6. #include "udp.h"
  7. #include "internet.h"
  8. #include "cmdparse.h"
  9. #include "commands.h"
  10.  
  11. static int doudpstat __ARGS((int argc,char *argv[],void *p));
  12.  
  13. static struct cmds Udpcmds[] = {
  14.     "status",    doudpstat, 0, 0, NULLCHAR,
  15.     NULLCHAR,
  16. };
  17. int
  18. doudp(argc,argv,p)
  19. int argc;
  20. char *argv[];
  21. void *p;
  22. {
  23.     if(argc == 1)
  24.         return doudpstat(argc,argv,p);
  25.     return subcmd(Udpcmds,argc,argv,p);
  26. }
  27.  
  28. int
  29. st_udp(udp,n)
  30. struct udp_cb *udp;
  31. int n;
  32. {
  33.     if(n == 0)
  34.         tprintf("    &UCB Rcv-Q  Local socket\n");
  35.  
  36.     return tprintf("%8lx%6u  %s\n",ptol(udp),udp->rcvcnt,pinet(&udp->socket));
  37. }
  38.  
  39. /* Dump UDP statistics and control blocks */
  40. static int
  41. doudpstat(argc,argv,p)
  42. int argc;
  43. char *argv[];
  44. void *p;
  45. {
  46.     register struct udp_cb *udp;
  47.     register int i;
  48.  
  49.     for(i=1;i<=NUMUDPMIB;i++){
  50.         tprintf("(%2u)%-20s%10lu",i,
  51.          Udp_mib[i].name,Udp_mib[i].value.integer);
  52.         if(i % 2)
  53.             tprintf("     ");
  54.         else
  55.             tprintf("\n");
  56.     }
  57.     if((i % 2) == 0)
  58.         tprintf("\n");
  59.  
  60.     tprintf("    &UCB Rcv-Q  Local socket\n");
  61.     for(i=0;i<NUDP;i++){
  62.         for(udp = Udps[i];udp != NULLUDP; udp = udp->next){
  63.             if(st_udp(udp,1) == EOF)
  64.                 return 0;
  65.         }
  66.     }
  67.     return 0;
  68. }
  69.